<template>
  <div class="search-result-item" v-show="searchItems.length > 0">
    <!-- 搜索结果类型 -->
    <div class="result-type">
      {{ searchType === 1 ? "联系人" : searchType === 2 ? "群聊" : "聊天记录" }}
    </div>

    <!-- 搜索类型内容 -->
    <div
      class="result-type-item"
      v-for="(item, index) in searchItems"
      :key="index"
    >
      <AvatarBase :width="35"></AvatarBase>

      <div class="info">
        <div class="title">{{ item.title }}</div>
        <div class="content">{{ item.content }}</div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import AvatarBase from "@/components/avatar/AvatarBase.vue";
import ResultItem from "./ResultItem.vue";

defineProps({
  searchType: {
    type: Number,
    default: 1,
  },

  searchItems: {
    type: Array,
    default: [],
  },
});
</script>

<style scoped lang="scss">
.search-result-item {
  width: 100%;
  background-color: #f7f7f7;
  display: flex;
  flex-direction: column;
  justify-content: center;

  .result-type {
    height: 30px;
    line-height: 30px;
    text-align: start;
    font-size: 13px;
    padding-left: 13px;

    color: #8d8d8d;
  }

  .result-type-item {
    height: 60px;
    padding: 13px;
    display: flex;
    align-items: center;

    &:hover {
      background-color: #ededed;
    }

    &:active {
      background-color: #eaeaea;
    }

    .info {
      height: 100%;
      flex: 1;

      margin-left: 13px;
      font-size: 14px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      line-height: 12px;

      .title {
        flex: 1;
      }

      .content {
        font-size: 12px;
      }
    }
  }
}
</style>
